Skip to content

fix: handle recursive watcher ignore paths correctly#13756

Open
ManManavadaria wants to merge 1 commit intodocker:mainfrom
ManManavadaria:13750-watch-ignore-fix
Open

fix: handle recursive watcher ignore paths correctly#13756
ManManavadaria wants to merge 1 commit intodocker:mainfrom
ManManavadaria:13750-watch-ignore-fix

Conversation

@ManManavadaria
Copy link
Copy Markdown

What I did
Applied ignore rules at the watcher layer and updated recursive traversal to skip ignored files/directories, ensuring permission errors from paths in the ignore list do not fail watch.

Related issue
fixes #13750

(not mandatory) A picture of a cute animal, if possible in relation to what you did

Signed-off-by: ManManavadaria <manmanavadaria@gmail.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to fix Docker Compose watch startup failures when an ignored path is unreadable by pushing ignore handling down into the watcher layer. In the codebase, that primarily affects how pkg/compose constructs file watchers and how pkg/watch traverses directories on different platforms.

Changes:

  • Added an ignore matcher parameter to the watcher API and threaded it through Compose watch setup.
  • Updated the naive watcher to skip ignored directories during recursive traversal and to suppress permission errors for ignored paths during startup walks.
  • Adjusted Darwin watcher and test fixture construction to use the new watcher signature.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
pkg/watch/watcher_naive.go Adds ignore-aware traversal and permission handling to the non-fsevents watcher implementation.
pkg/watch/watcher_darwin.go Updates the Darwin watcher constructor signature to match the new watcher API.
pkg/watch/notify_test.go Updates test fixture setup to call NewWatcher with an ignore matcher.
pkg/watch/notify.go Extends the exported watcher constructor to accept an ignore matcher.
pkg/compose/watch.go Builds ignore matchers from watch triggers and passes them into watcher creation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +277 to +285
matches, err := d.ignore.MatchesEntireDir(path)
if err != nil {
logrus.Debugf("error checking ignored directory %q: %v", path, err)
return false
}
if matches {
return true
}
matches, err = d.ignore.Matches(path)
Comment on lines +117 to +120
if os.IsPermission(err) && d.shouldIgnore(path) {
logrus.Debugf("Ignoring path: %s", path)
return nil
}
Comment thread pkg/compose/watch.go
}

watcher, err := watch.NewWatcher(paths)
watcher, err := watch.NewWatcher(paths, watch.NewCompositeMatcher(ignoreMatchers...))
}

func newWatcher(paths []string) (Notify, error) {
func newWatcher(paths []string, _ PathMatcher) (Notify, error) {
Comment on lines +117 to +119
if os.IsPermission(err) && d.shouldIgnore(path) {
logrus.Debugf("Ignoring path: %s", path)
return nil
@codecov
Copy link
Copy Markdown

codecov Bot commented May 4, 2026

Codecov Report

❌ Patch coverage is 58.06452% with 13 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/watch/watcher_naive.go 47.61% 8 Missing and 3 partials ⚠️
pkg/compose/watch.go 75.00% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] watch tries to read ignored folders leading to permission denied

2 participants